package org.sippr.rvt2ifc.controller;

import com.fasterxml.jackson.databind.JsonNode;
import org.sippr.rvt2ifc.pojo.ProjectMark;
import org.sippr.rvt2ifc.pojo.Result;
import org.sippr.rvt2ifc.pojo.User;
import org.sippr.rvt2ifc.service.ProjectMarkService;
import org.sippr.rvt2ifc.utils.EEPUtil;
import org.sippr.rvt2ifc.utils.JwtUtil;
import org.sippr.rvt2ifc.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@CrossOrigin(origins = "http://localhost:8081") // 允许指定前端地址访问
@RestController
@RequestMapping("/mark")
@Validated//字符串长度等合法性校验
public class ProjectMarkController {
    @Autowired
    private ProjectMarkService projectMarkService;

    @PostMapping("/insert")
    public Result insert(@RequestBody ProjectMark value) {

        ProjectMark mark = projectMarkService.insert(value);
        if (mark != null)
            return Result.success(mark);
        return Result.error("失败！");
    }

    @GetMapping("/list")
    public Result<List<ProjectMark>> list(String projectUuid) {
        List<ProjectMark> list = projectMarkService.list(projectUuid);
        return Result.success(list);
    }

    @PostMapping("/update")
    public Result update(@RequestBody ProjectMark projectMark) {
        projectMarkService.updateContent(projectMark);
        return Result.success();
    }

    @DeleteMapping("/delete")
    public Result delete(@RequestBody String uuid) {
        projectMarkService.delete(uuid);
        return Result.success();
    }
}
